import {
	createStore
} from "vuex";
export default createStore({
	state: {
		userInfo: {},
		common: {}
	},
	mutations: {
		// 定义mutations，用于修改状态(同步)
		changeUserInfo(state, data) {
			state.userInfo = data
			uni.setStorageSync('userInfo', JSON.stringify(data))
		},

	},
	actions: {
		getuserInfoAPI(context) {
			getuserInfo().then((res) => {
				if (res && res.code == 1) {
					context.commit("changeUserInfo", res.data.userinfo)
				}
			})
		},
	},
	getters: {
		// 定义一个getters
		formatUid(state) {
			return state.uid + ' Tom'
		}
	},
	modules: {}
});